home *** CD-ROM | disk | FTP | other *** search
- /*
- CDStatus - An XFCN to return CDROM status
- ©Apple Computer, Inc. 1988
- All Rights Reserved.
-
- 88/11/08 BL°B First Version
-
- To compile and link this file using Macintosh Programmer's Workshop,
-
- C -q2 CDStatus.c
- link -sn Main=CDStatus -sn STDIO=CDStatus ∂
- -sn INTENV=CDStatus -rt XFCN=42 ∂
- -m CDStatus CDStatus.c.o "{CLibraries}"CRuntime.o ∂
- "{CLibraries}"StdCLib.o ∂
- -o HyperCommands
-
- This link directive puts the XCMD in the file "HyperCommands".
- Substitute the name of the stack you want it in. To move XCMDs
- between stacks, use ResEdit. They can be in an individual stack,
- the Home stack, the HyperCard application, or the System File.
-
- */
-
- #include <cd.h>
-
- /* prototype definitions for functions */
- OSErr AStatus(short, short *);
-
- /* **** WARNING: DO NOT USE GLOBAL VARIABLES! **** */
-
-
- /************************************************************************
- *
- * Function: CDStatus
- *
- * Purpose: return cd audio status
- *
- * Returns: a status value, or a negative error value.
- * 0 = audio pause in progress
- * 1 = audio play in progress
- * 2 = audio muting on
- * 3 = audio play operation completed
- * 4 = error occurred during audio play
- * 5 = not currently playing
- *
- * -1 = incorrect number of parameters
- * other errors are from the driver. See the
- * developer's guide for more details.
- *
- * Side Effects:
- *
- * Description: We need no parameter. Get the ioRefNum from the
- * famous global set by CDOpen(). Call the driver to get
- * status, and return it.
- *
- * If the status is 0, return 1. If the status is 1,
- * return 0. This makes for a convenient consistent
- * interface for the user (0 always means pause).
- *
- ************************************************************************/
- pascal void
- CDStatus(paramPtr)
- XCmdBlockPtr paramPtr;
- {
- Str31 returnString;
- OSErr result;
- short status;
- short ioRefNum;
- Handle refHandle;
-
- /* Must be only no parameter */
- if ((paramPtr->paramCount) != 0)
- {
- /* Report error in parameters by returning -1 */
- NumToStr(paramPtr, (long) -1, &returnString);
- paramPtr->returnValue = PasToZero(paramPtr, (StringPtr) &returnString);
- return;
- }
-
- /* Get the global ioRefNum and convert it. */
- refHandle = GetGlobal(paramPtr, GLOBALNAME);
- ioRefNum = atoi(*(refHandle));
- DisposHandle(refHandle);
- ioRefNum &= 0xFFFF; /* remove vRefNum; not needed. */
-
- result = AStatus(ioRefNum, &status);
-
- if (result == noErr)
- {
- if (status == 1) /* for consistency. pause is always reported as 0 */
- status = 0;
- else if (status == 0)
- status = 1;
- /* Convert status to string & return it */
- NumToStr(paramPtr, (long) status, &returnString);
- paramPtr->returnValue = PasToZero(paramPtr, (StringPtr) &returnString);
- }
- else
- {
- /* Convert result to string & return it as error */
- NumToStr(paramPtr, (long) result, &returnString);
- paramPtr->returnValue = PasToZero(paramPtr, (StringPtr) &returnString);
- }
- }
-
- /************************************************************************
- *
- * Function: AStatus
- *
- * Purpose: return CD audio status
- *
- * Returns: OSErr. Probably either
- * noErr everything's hunky-dory!
- * paramErr you messed up the call somehow.
- *
- * Side Effects: modifies "status" to reflect the audio status byte
- * returned by the driver.
- *
- * Description: Simply call the driver and return the audio status
- * byte that the driver gives us.
- *
- ************************************************************************/
- OSErr
- AStatus(refNum, status)
- short refNum;
- short *status;
- {
- CDStatusParam myPB;
- OSErr result;
-
- myPB.ioCompletion = 0;
- myPB.ioNamePtr = (char *) 0;
- myPB.ioVRefNum = 1;
- myPB.ioCRefNum = refNum;
- myPB.csCode = ASTATUS;
-
- result = PBControl(&myPB, false);
- *status = (short) myPB.audioStatus;
- return result;
- }
-
-
- /* C routines for HyperCard callbacks */
- #include <XCmdGlue.inc.c>
-